#ifndef __CD4051_H
#define __CD4051_H
#include "app.h"
#include "common.h"
#include "stm32f10x.h"
#include "ucos_ii.h"
// 定义端口
#define ADG_PORT     GPIOD
#define ADG_GPIO_CLK RCC_APB2Periph_GPIOD

#define ADG0_A0_PIN GPIO_Pin_13
#define ADG0_A1_PIN GPIO_Pin_12
#define ADG0_A2_PIN GPIO_Pin_11

#define ADG1_A0_PIN GPIO_Pin_10
#define ADG1_A1_PIN GPIO_Pin_9
#define ADG1_A2_PIN GPIO_Pin_8

#define CHIP_NUM    2   // 芯片个数
#define CH_NUM      8   // 8通道
#define SAMPLES_NUM 5   // 5 次采样

void     ADG_Init(void);
void     ADG_SelectChannel(uint8_t index, uint8_t ch);
void     CD4051_proc(uint8_t index);
void     cd_fifo_enqueue(uint8_t index, u16 data, u16 count);
u16      Cd_Aver_Filter_u16(uint8_t index, u16* buffer, INT8U num);
uint16_t Get_CD4051(uint8_t index, uint8_t ch);
#endif
